//
//  PaymentViewController.m
//  Manage
//
//  Created by 杨康 on 2018/1/10.
//  Copyright © 2018年 杨康. All rights reserved.
//

#import "PaymentViewController.h"
#import "CertificationViewController.h"
@interface PaymentViewController ()
{
    UIButton *_selectButton;
}
@end

@implementation PaymentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"交纳押金";
    
    UILabel *titleLab=[SingLeton myLabel:[UIColor color6] andTitle:@"押金" andFont:14];
    [self.view addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(TOP_HEIGHT+30);
        
    }];
    
    
    UILabel *numLab=[SingLeton myLabel:[UIColor colorWithHexString:@"222222"] andTitle:@"1000.00" andFont:20];
    [self.view addSubview:numLab];
    [numLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(titleLab.mas_bottom).mas_offset(11);
    }];
    
    
    UILabel *tipLab=[SingLeton myLabel:[UIColor color9] andTitle:@"押金随时退，安全速到账" andFont:14];
    [self.view addSubview:tipLab];
    [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(numLab.mas_bottom).mas_offset(20);
    }];
    
    
    UILabel *typeLab=[SingLeton myLabel:[UIColor color6] andTitle:@"支付方式" andFont:14];
    [self.view addSubview:typeLab];
    [typeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(tipLab.mas_bottom).mas_offset(50);
    }];
    
    
    UIImageView *zfbImg=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"支付宝"]];
    [self.view addSubview:zfbImg];
    [zfbImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(typeLab.mas_bottom).mas_offset(20);
    }];
    
    UILabel *zfbLab=[SingLeton myLabel:[UIColor color3] andTitle:@"支付宝" andFont:17];
    [self.view addSubview:zfbLab];
    [zfbLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(zfbImg);
        make.left.mas_equalTo(zfbImg.mas_right).mas_offset(10);
    }];
    
    
    UIButton *zfbButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:zfbButton];
    [zfbButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(zfbImg);
        make.right.mas_equalTo(-30);
        make.size.mas_equalTo(CGSizeMake(100, 30));
    }];
    
    [zfbButton setImage:[UIImage imageNamed:@"可选"] forState:UIControlStateNormal];
    [zfbButton setImage:[UIImage imageNamed:@"选择"] forState:UIControlStateSelected];
    zfbButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [zfbButton addTarget:self action:@selector(payAction:) forControlEvents:UIControlEventTouchUpInside];
    [self payAction:zfbButton];
    
    UIImageView *wxImg=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"微信支付"]];
    [self.view addSubview:wxImg];
    [wxImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(zfbImg.mas_bottom).mas_offset(20);
    }];
    
    UILabel *wxLab=[SingLeton myLabel:[UIColor color3] andTitle:@"微信支付" andFont:17];
    [self.view addSubview:wxLab];
    [wxLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(wxImg);
        make.left.mas_equalTo(wxImg.mas_right).mas_offset(10);
    }];
    
    
    UIButton *wxButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:wxButton];
    [wxButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(wxImg);
        make.right.mas_equalTo(-30);
        make.size.mas_equalTo(CGSizeMake(100, 30));
    }];
    
    [wxButton setImage:[UIImage imageNamed:@"可选"] forState:UIControlStateNormal];
    [wxButton setImage:[UIImage imageNamed:@"选择"] forState:UIControlStateSelected];
    wxButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [wxButton addTarget:self action:@selector(payAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *payButton=[SingLeton endButton:[UIColor colorWithHexString:@"09be00"] andTitle:@"交纳押金" RequestSuccess:^(UIButton *btn) {
        CertificationViewController *vc=[[CertificationViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }];
    [self.view addSubview:payButton];
    [payButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.bottom.mas_equalTo(-20);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-40, 44));
    }];
    
    
    
}

-(void)payAction:(UIButton *)btn
{
    
    if (_selectButton) {
        _selectButton.selected=NO;
    }
    
    _selectButton=btn;
    btn.selected=YES;
}

@end
